<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hadoop," />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.2" />






<meta name="description" content="环境  123456789hdp21 192.168.95.21hdp22 192.168.95.22hdp23 192.168.95.23hdp24 192.168.95.24hdp25 192.168.95.25时间网络同步、关闭selinux创建用户hadoop，密码fujghadoop 用户免密登录我准备把所有的文件都放在home目录下  Hadoop2.7.3  12345192.16">
<meta name="keywords" content="Hadoop">
<meta property="og:type" content="article">
<meta property="og:title" content="Hadoop集群双NameNode">
<meta property="og:url" content="http://www.gaohy.top/2018/01/18/Hadoop集群双NameNode/index.html">
<meta property="og:site_name" content="Mr、Gao个人小屋">
<meta property="og:description" content="环境  123456789hdp21 192.168.95.21hdp22 192.168.95.22hdp23 192.168.95.23hdp24 192.168.95.24hdp25 192.168.95.25时间网络同步、关闭selinux创建用户hadoop，密码fujghadoop 用户免密登录我准备把所有的文件都放在home目录下  Hadoop2.7.3  12345192.16">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://www.gaohy.top/images/%E5%9B%BE%E7%89%87%201.png">
<meta property="og:image" content="http://www.gaohy.top/images/2.png">
<meta property="og:updated_time" content="2018-01-18T06:04:25.797Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Hadoop集群双NameNode">
<meta name="twitter:description" content="环境  123456789hdp21 192.168.95.21hdp22 192.168.95.22hdp23 192.168.95.23hdp24 192.168.95.24hdp25 192.168.95.25时间网络同步、关闭selinux创建用户hadoop，密码fujghadoop 用户免密登录我准备把所有的文件都放在home目录下  Hadoop2.7.3  12345192.16">
<meta name="twitter:image" content="http://www.gaohy.top/images/%E5%9B%BE%E7%89%87%201.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Mist',
    version: '5.1.2',
    sidebar: {"position":"left","display":"hide","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://www.gaohy.top/2018/01/18/Hadoop集群双NameNode/"/>





  <title>Hadoop集群双NameNode | Mr、Gao个人小屋</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Mr、Gao个人小屋</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">不积跬步无以至千里</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://www.gaohy.top/blog/2018/01/18/Hadoop集群双NameNode/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Mr、Gao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/IMG_0071.JPG">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Mr、Gao个人小屋">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Hadoop集群双NameNode</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-01-18T19:48:11+08:00">
                2018-01-18
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于&#58;</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2018-01-18T14:04:25+08:00">
                2018-01-18
              </time>
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Hadoop/" itemprop="url" rel="index">
                    <span itemprop="name">Hadoop</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i> 阅读数
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <ul>
<li>环境</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">hdp21</span> 192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.21</span></div><div class="line"><span class="selector-tag">hdp22</span> 192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.22</span></div><div class="line"><span class="selector-tag">hdp23</span> 192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.23</span></div><div class="line"><span class="selector-tag">hdp24</span> 192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.24</span></div><div class="line"><span class="selector-tag">hdp25</span> 192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.25</span></div><div class="line">时间网络同步、关闭<span class="selector-tag">selinux</span></div><div class="line">创建用户<span class="selector-tag">hadoop</span>，密码<span class="selector-tag">fujg</span></div><div class="line"><span class="selector-tag">hadoop</span> 用户免密登录</div><div class="line">我准备把所有的文件都放在<span class="selector-tag">home</span>目录下</div></pre></td></tr></table></figure>
<ul>
<li>Hadoop2.7.3</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.21</span>  <span class="selector-tag">hdp21</span>  主<span class="selector-tag">NameNode</span></div><div class="line">192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.22</span>  <span class="selector-tag">hdp22</span>  备用<span class="selector-tag">NameNode</span></div><div class="line">192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.23</span>  <span class="selector-tag">hdp23</span>  <span class="selector-tag">DataNode</span></div><div class="line">192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.24</span>  <span class="selector-tag">hdp24</span>  <span class="selector-tag">DataNode</span></div><div class="line">192<span class="selector-class">.168</span><span class="selector-class">.95</span><span class="selector-class">.25</span>  <span class="selector-tag">hdp25</span>  <span class="selector-tag">DataNode</span></div></pre></td></tr></table></figure>
<h1 id="1-准备"><a href="#1-准备" class="headerlink" title="1.准备"></a>1.准备</h1><figure class="highlight arduino"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="number">1</span>，解压安装包到<span class="built_in">home</span>目录</div><div class="line">tar –zxvf hadoop<span class="number">-2.7</span><span class="number">.3</span>.tar.gz –C /<span class="built_in">home</span>/</div><div class="line"><span class="number">2</span>，修改<span class="built_in">home</span>的权限</div><div class="line">chmod <span class="number">777</span> /<span class="built_in">home</span></div><div class="line"><span class="number">3</span>，创建目录</div><div class="line"><span class="built_in">mkdir</span> -pv /<span class="built_in">home</span>/dfs/&#123;data,name&#125;</div><div class="line"><span class="built_in">mkdir</span> /<span class="built_in">home</span>/tmp</div><div class="line"><span class="built_in">mkdir</span> -pv /<span class="built_in">home</span>/hadoop<span class="number">-2.7</span><span class="number">.3</span>/&#123;journal,mapred_local,mapred_system,mr-history&#125;</div><div class="line"><span class="built_in">mkdir</span> -pv /<span class="built_in">home</span>/hadoop<span class="number">-2.7</span><span class="number">.3</span>/mr-history/&#123;done,tmp&#125;</div></pre></td></tr></table></figure>
<h1 id="2-编辑配置文件"><a href="#2-编辑配置文件" class="headerlink" title="2.  编辑配置文件"></a>2.  编辑配置文件</h1><h2 id="2-1-core-site-xml"><a href="#2-1-core-site-xml" class="headerlink" title="2.1  core-site.xml"></a>2.1  core-site.xml</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- hdfs访问端口，这里看hdfs-site.xml中配置的端口，双机 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>fs.defaultFS<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdfs://ns<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 临时文件目录 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>hadoop.tmp.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/tmp<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 缓存的大小，单位为byte，默认4k，线上设置为40k，这里设置4k --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>io.file.buffer.size<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>4096<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定zookeeper地址 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>ha.zookeeper.quorum<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21:2181,hdp22:2181,hdp23:2181,hdp24:2181,hdp25:2181<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 用户代理机制 属组 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>hadoop.proxyuser.hadoop.groups<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hadoop<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 用户代理机制 hosts --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>hadoop.proxyuser.hadoop.hosts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>192.168.95.21<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!-- snappy 文件压缩 --&gt;</span></div><div class="line">    <span class="comment">&lt;!--&lt;property&gt;</span></div><div class="line"><span class="comment">        &lt;name&gt;io.compression.codecs&lt;/name&gt;</span></div><div class="line"><span class="comment">        &lt;value&gt;</span></div><div class="line"><span class="comment">            org.apache.hadoop.io.compress.GzipCodec,</span></div><div class="line"><span class="comment">            org.apache.hadoop.io.compress.DefaultCodec,</span></div><div class="line"><span class="comment">            org.apache.hadoop.io.compress.BZip2Codec,</span></div><div class="line"><span class="comment">            org.apache.hadoop.io.compress.SnappyCodec</span></div><div class="line"><span class="comment">        &lt;/value&gt;</span></div><div class="line"><span class="comment">    &lt;/property&gt;</span></div><div class="line"><span class="comment">    --&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div></pre></td></tr></table></figure>
<h2 id="2-2-hdfs-site-xml"><a href="#2-2-hdfs-site-xml" class="headerlink" title="2.2  hdfs-site.xml"></a>2.2  hdfs-site.xml</h2><figure class="highlight dust"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div></pre></td><td class="code"><pre><div class="line"><span class="xml"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 指定hdfs的nameservice为ns，要与core-site.xml中的名字一致 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.nameservices<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>ns<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- ns下面配置两个nameNode，nn1、nn2 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.ha.namenodes.ns<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>nn1,nn2<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- nn1的RPC通信地址 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.rpc-address.ns.nn1<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21:9000<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- nn1的HTTP通信地址 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.http-address.ns.nn1<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21:50070<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- nn2的RPC通信地址 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.rpc-address.ns.nn2<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp22:9000<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- nn2的HTTP通信地址 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.http-address.ns.nn2<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp22:50070<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 指定NameNode的元数据 在JournalNode上的存放位置，使用以下3个节点存储 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.shared.edits.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>qjournal://hdp23:8485;hdp24:8485;hdp25:8485/ns<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 指定JournalNode在本地磁盘存放数据的位置 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.journalnode.edits.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/journal<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 开启NameNode故障时自动切换 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.ha.automatic-failover.enabled<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 失败自动切换实现方式 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.client.failover.proxy.provider.ns<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 配置隔离机制，如果ssh是默认22端口，value直接写sshfence即可 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.ha.fencing.methods<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>sshfence<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 使用隔离机制时，需要ssh免密登录 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.ha.fencing.ssh.private-key-files<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop/.ssh/id_rsa<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 元数据文件目录，默认为//$</span></span><span class="template-variable">&#123;hadoop.tmp.dir&#125;</span><span class="xml"><span class="comment">/dfs/name，这里的hadoop.tmp.dir是core-site.xml中配置的临时文件目录 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.name.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>file:/home/dfs/name<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 数据目录 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.datanode.data.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>file:/home/dfs/data<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 副本的冗余数量，正常应该是三个 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.replication<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>3<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 在nn和dn上开启webHDFS (REST API) 功能，不是必须 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.webhdfs.enabled<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    </span></div><div class="line"><span class="xml">    <span class="comment">&lt;!-- 数据节点 追加 start --&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 是否开启数据节点追加，默认为true，当节点很少(即，节点宕掉了没有新的节点可提供)时，应该关闭 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.client.block.write.replace-datanode-on-failure.enable<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 数据节点追加，当上一个设置为true时起作用 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.client.block.write.replace-datanode-on-failure.policy<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>NEVER<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="comment">&lt;!-- 数据节点 追加 end --&gt;</span></span></div><div class="line"><span class="xml">    </span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 权限检查开关，只有在有权限的环境中有用 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.permissions<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>false<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- webserver使用的用户名，','分隔添加用户组 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.web.ugi<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hadoop,hadoop<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 超时时间，单位 毫秒 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.socket.timeout<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>240000<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 指定用于在DataNode间传输block数据的最大线程数，默认4096 线上配置为40960 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.datanode.max.transfer.threads<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>4096<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 打开文件数量上限，不能超过系统打开文件数设置 线上配置40960 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.datanode.max.xcievers<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>4096<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- datanode同时处理客户端请求线程数，默认为10 线上配置500 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.datanode.handler.count<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>50<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- namenode线程数，越大消耗内存越大 线上配置500 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.namenode.handler.count<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>50<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="comment">&lt;!-- 动态增删节点，下面两项配置，运行hadoop dfsadmin -refreshNodes 即可使其生效 --&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 节点写在文件中 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.hosts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/etc/hadoop/slaves<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="comment">&lt;!-- 要删除的节点写在文件中 --&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.hosts.exclude<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span></div><div class="line"><span class="xml">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/etc/hadoop/exclude-slaves<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span></div><div class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></span></div><div class="line"><span class="xml"></span></div><div class="line"><span class="xml"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span></div></pre></td></tr></table></figure>
<h2 id="2-3-mapred-site-xml"><a href="#2-3-mapred-site-xml" class="headerlink" title="2.3  mapred-site.xml"></a>2.3  mapred-site.xml</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line">    </div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定map reduce运行在YARN上 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.framework.name<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>yarn<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- mapreduce共享目录，MapReduce的控制文件 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapred.system.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/mapred_system<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- MapReduce产生的中间数据存放目录,以,号隔开,hdfs会把数据存在这些目录下，一般这些目录是不同的块设备，不存在的目录会被忽略掉 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapred.local.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/mapred_local<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- mapreduce历史作业服务:端口 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.address<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21:10020<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- mapreduce历史作业  web ui 服务:端口 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.webapp.address<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21:19888<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- mapreduce正在运行作业信息目录 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.intermediate-done-dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/mr-history/tmp<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- mapreduce已完成作业信息目录 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.done-dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>/home/hadoop-2.7.3/mr-history/done<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!-- JVM参数 --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 每个map或reduce使用的内存数量，线上512m --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapred.child.java.opts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>-Xmx200M<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- reduce使用的内存数量，线上512m --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapred.reduce.child.java.opts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>-Xmx200M<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- map使用的内存数量，线上512m --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapred.map.child.java.opts<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>-Xmx200M<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div></pre></td></tr></table></figure>
<h2 id="2-4-yarn-site-xml"><a href="#2-4-yarn-site-xml" class="headerlink" title="2.4  yarn-site.xml"></a>2.4  yarn-site.xml</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></div><div class="line"></div><div class="line"><span class="comment">&lt;!-- Site specific YARN configuration properties --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 辅助服务，扩展自己的功能 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.nodemanager.aux-services<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>mapreduce_shuffle<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.nodemanager.aux-services.mapreduce_shuffle.class<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>org.apache.hadoop.mapred.ShuffleHandler<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 开启RM高可用，ha高可用集群，这里是双机 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.ha.enabled<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 自动故障切换 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.ha.automatic-failover.enabled<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>true<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定RM的名字 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.ha.rm-ids<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>rm1,rm2<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!--  --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.zk-address<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp23:2181,hdp24:2181,hdp25:2181<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定rm1的地址 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.hostname.rm1<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp21<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定rm2的地址 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.hostname.rm2<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdp22<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 指定RM的cluster集群 id --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.cluster-id<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>yrc<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span>&gt;</span></div><div class="line">        <span class="comment">&lt;!-- 该节点上YARN可使用的物理内存总量，默认是8192（MB），YARN不会智能的探测节点的物理内存总量，线上是16372 --&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.nodemanager.resource.memory-mb<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>512<span class="tag">&lt;/<span class="name">value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">property</span>&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></div></pre></td></tr></table></figure>
<h2 id="2-5-slaves"><a href="#2-5-slaves" class="headerlink" title="2.5  slaves"></a>2.5  slaves</h2><figure class="highlight smali"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">hdp23</div><div class="line">hdp24</div><div class="line">hdp25</div></pre></td></tr></table></figure>
<h2 id="2-6-修改hadoop-env-sh"><a href="#2-6-修改hadoop-env-sh" class="headerlink" title="2.6  修改hadoop-env.sh"></a>2.6  修改hadoop-env.sh</h2><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">vim /home/hadoop-2.7.3/etc/hadoop/hadoop-env.sh</div><div class="line">把原来的<span class="builtin-name">export</span> <span class="attribute">JAVA_HOME</span>=<span class="variable">$&#123;JAVA_HOME&#125;</span></div><div class="line">修改为<span class="builtin-name">export</span> JAVA_HOME= /usr/local/jdk1.7.0_71</div><div class="line">即真实的jdk安装路径</div></pre></td></tr></table></figure>
<h2 id="2-7-复制配置到其他节点"><a href="#2-7-复制配置到其他节点" class="headerlink" title="2.7  复制配置到其他节点"></a>2.7  复制配置到其他节点</h2><figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">cd</span> <span class="string">/home/</span></div><div class="line">scp -r hadoop-2.7.3/ hdp22:<span class="string">/home/</span></div><div class="line">scp -r hadoop-2.7.3/ hdp23:<span class="string">/home/</span></div><div class="line">scp -r hadoop-2.7.3/ hdp24:<span class="string">/home/</span></div><div class="line">scp -r hadoop-2.7.3/ hdp25:<span class="string">/home/</span></div></pre></td></tr></table></figure>
<h1 id="3-环境变量"><a href="#3-环境变量" class="headerlink" title="3  环境变量"></a>3  环境变量</h1><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">su root</div><div class="line">vim /etc/profile.d/hadoop.sh</div><div class="line"><span class="builtin-name">export</span> <span class="attribute">HADOOP_HOME</span>=/home/hadoop-2.7.3</div><div class="line"><span class="builtin-name">export</span> <span class="attribute">PATH</span>=<span class="variable">$PATH</span>:$&#123;HADOOP_HOME&#125;/bin:<span class="variable">$&#123;HADOOP_HOME&#125;</span>/sbin</div><div class="line">复制到其他节点：scp /etc/profile.d/hadoop.sh hdp22: /etc/profile.d/</div><div class="line">执行使配置立即生效 . /etc/profile.d/hadoop.sh</div></pre></td></tr></table></figure>
<h1 id="4-为启动准备"><a href="#4-为启动准备" class="headerlink" title="4  为启动准备"></a>4  为启动准备</h1><h2 id="4-1-zookeeper"><a href="#4-1-zookeeper" class="headerlink" title="4.1  zookeeper"></a>4.1  zookeeper</h2><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">启动<span class="selector-tag">zookeeper</span>，<span class="selector-tag">zk-bat</span><span class="selector-class">.sh</span> <span class="selector-tag">start</span></div><div class="line"><span class="selector-tag">Zookeeper</span>已经安装完成 <span class="selector-tag">zk-bat</span><span class="selector-class">.sh</span>是我写的启动脚本</div></pre></td></tr></table></figure>
<h2 id="4-2-创建zk命名空间"><a href="#4-2-创建zk命名空间" class="headerlink" title="4.2  创建zk命名空间"></a>4.2  创建zk命名空间</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">在主NameNode节点上执行（创建命名空间）：</div><div class="line">hdfs zkfc -formatZK</div></pre></td></tr></table></figure>
<h2 id="4-3-JournalNode"><a href="#4-3-JournalNode" class="headerlink" title="4.3  JournalNode"></a>4.3  JournalNode</h2><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">在各个DataNode节点上执行（启动<span class="keyword">journalnode）：</span></div><div class="line"><span class="keyword">hadoop-daemon.sh </span>start <span class="keyword">journalnode</span></div><div class="line"><span class="keyword">使用jps查看服务是否启动</span></div></pre></td></tr></table></figure>
<h2 id="4-4-格式化hdfs"><a href="#4-4-格式化hdfs" class="headerlink" title="4.4  格式化hdfs"></a>4.4  格式化hdfs</h2><figure class="highlight dos"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">格式化namenode和journalnode目录</div><div class="line">hdfs namenode -<span class="built_in">format</span> ns</div></pre></td></tr></table></figure>
<h2 id="4-5-启动namenode"><a href="#4-5-启动namenode" class="headerlink" title="4.5  启动namenode"></a>4.5  启动namenode</h2><figure class="highlight stylus"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="number">1</span>，在主namenode节点启动namenode进程（hdp21，只在一个NameNode上执行即可）</div><div class="line">hadoop-daemon<span class="selector-class">.sh</span> start namenode</div><div class="line"><span class="number">2</span>，复制主NameNode（在hdp22上，把备namenode节点的目录格式化并把元数据从主namenode节点copy过来，并且这个命令不会把journalnode目录再格式化了）：</div><div class="line">hdfs namenode –bootstrapStandby</div><div class="line"><span class="number">3</span>，启动备namenode进程（在hdp22上执行）</div><div class="line">hadoop-daemon<span class="selector-class">.sh</span> start namenode</div><div class="line"><span class="number">4</span>，在两个NameNode上都执行：</div><div class="line">hadoop-daemon<span class="selector-class">.sh</span> start zkfc</div></pre></td></tr></table></figure>
<h2 id="4-6-启动DataNode"><a href="#4-6-启动DataNode" class="headerlink" title="4.6  启动DataNode"></a>4.6  启动DataNode</h2><figure class="highlight stylus"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">在所有的DataNode上执行（启动datanode）：</div><div class="line">hadoop-daemon<span class="selector-class">.sh</span> start datanode</div></pre></td></tr></table></figure>
<h1 id="5-启停"><a href="#5-启停" class="headerlink" title="5  启停"></a>5  启停</h1><figure class="highlight vim"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">启动</div><div class="line">start-dfs.<span class="keyword">sh</span></div><div class="line">停止</div><div class="line"><span class="keyword">stop</span>-dfs.<span class="keyword">sh</span></div></pre></td></tr></table></figure>
<h1 id="6-监控等"><a href="#6-监控等" class="headerlink" title="6  监控等"></a>6  监控等</h1><ul>
<li>hdp21主NameNode</li>
</ul>
<figure class="highlight dts"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">Hdfs浏览器访问地址：</div><div class="line"><span class="symbol">http:</span><span class="comment">//hdp21:50070</span></div></pre></td></tr></table></figure>
<ul>
<li>hdp22备NameNode</li>
</ul>
<figure class="highlight dts"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">Hdfs浏览器访问地址：</div><div class="line"><span class="symbol">http:</span><span class="comment">//hdp22:50070</span></div></pre></td></tr></table></figure>
<ul>
<li>测试NameNode双机<br>杀掉主NameNode，即hdp21上的NameNode进程，浏览器查看hdp22的状态</li>
</ul>
<p>1.在hdp21上jps，找到NameNode进程id并杀掉<br><img src="/images/%E5%9B%BE%E7%89%87%201.png" alt="图片 1"></p>
<p>2.浏览器查看备NameNode状态</p>
<p><img src="/images/2.png" alt="2"></p>
<p>备用NameNode已经启动了！！！</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/Hadoop/" rel="tag"># Hadoop</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/01/11/Centos7安装hadoop2.7.5（单节点）/" rel="next" title="Centos7安装hadoop2.7.5（单节点）">
                <i class="fa fa-chevron-left"></i> Centos7安装hadoop2.7.5（单节点）
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/01/18/HDFS详解 /" rel="prev" title="HDFS特点">
                HDFS特点 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zMTAxMy83NTYy"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="/blog/images/IMG_0071.JPG"
              alt="Mr、Gao" />
          
            <p class="site-author-name" itemprop="name">Mr、Gao</p>
            <p class="site-description motion-element" itemprop="description">不积跬步无以至千里</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/blog/archives/">
            
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories/index.html">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/blog/tags/index.html">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/ghycn" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>GitHub</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="mailto:349111145@gmail.com" target="_blank" title="E-Mail">
                  
                    <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-准备"><span class="nav-number">1.</span> <span class="nav-text">1.准备</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-编辑配置文件"><span class="nav-number">2.</span> <span class="nav-text">2.  编辑配置文件</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#2-1-core-site-xml"><span class="nav-number">2.1.</span> <span class="nav-text">2.1  core-site.xml</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-2-hdfs-site-xml"><span class="nav-number">2.2.</span> <span class="nav-text">2.2  hdfs-site.xml</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-3-mapred-site-xml"><span class="nav-number">2.3.</span> <span class="nav-text">2.3  mapred-site.xml</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-4-yarn-site-xml"><span class="nav-number">2.4.</span> <span class="nav-text">2.4  yarn-site.xml</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-5-slaves"><span class="nav-number">2.5.</span> <span class="nav-text">2.5  slaves</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-6-修改hadoop-env-sh"><span class="nav-number">2.6.</span> <span class="nav-text">2.6  修改hadoop-env.sh</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-7-复制配置到其他节点"><span class="nav-number">2.7.</span> <span class="nav-text">2.7  复制配置到其他节点</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-环境变量"><span class="nav-number">3.</span> <span class="nav-text">3  环境变量</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#4-为启动准备"><span class="nav-number">4.</span> <span class="nav-text">4  为启动准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#4-1-zookeeper"><span class="nav-number">4.1.</span> <span class="nav-text">4.1  zookeeper</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-2-创建zk命名空间"><span class="nav-number">4.2.</span> <span class="nav-text">4.2  创建zk命名空间</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-3-JournalNode"><span class="nav-number">4.3.</span> <span class="nav-text">4.3  JournalNode</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-4-格式化hdfs"><span class="nav-number">4.4.</span> <span class="nav-text">4.4  格式化hdfs</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-5-启动namenode"><span class="nav-number">4.5.</span> <span class="nav-text">4.5  启动namenode</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-6-启动DataNode"><span class="nav-number">4.6.</span> <span class="nav-text">4.6  启动DataNode</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#5-启停"><span class="nav-number">5.</span> <span class="nav-text">5  启停</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#6-监控等"><span class="nav-number">6.</span> <span class="nav-text">6  监控等</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2017 &mdash; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Mr、Gao</span>

  
</div>
<!--

  <div class="powered-by">由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动</div>

  <span class="post-meta-divider">|</span>

  <div class="theme-info">
 <span>Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a></span>
  </div>

-->
        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 访问人数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.2"></script>



  
  

  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  








  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/blog/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  

  

  

</body>
</html>
